package k8s

import "time"

// CreateDeploymentFromYamlStrRequest 创建Deployment请求结构体
type CreateDeploymentFromYamlStrRequest struct {
	YamlStr string `json:"yaml_str" validate:"required"` // YAML字符串
}

// NewDefaultCreateDeploymentFromYamlStrRequest 创建默认的CreateDeploymentFromYamlStr请求
func NewDefaultCreateDeploymentFromYamlStrRequest() *CreateDeploymentFromYamlStrRequest {
	return &CreateDeploymentFromYamlStrRequest{}
}

// NewCreateDeploymentFromYamlStrRequest 创建CreateDeploymentFromYamlStr请求
func NewCreateDeploymentFromYamlStrRequest(yamlStr string) *CreateDeploymentFromYamlStrRequest {
	return &CreateDeploymentFromYamlStrRequest{
		YamlStr: yamlStr,
	}
}

// DeleteDeploymentRequest 删除Deployment请求结构体
type DeleteDeploymentRequest struct {
	Name string `json:"name" validate:"required"` // Deployment名称
}

// NewDefaultDeleteDeploymentRequest 创建默认的DeleteDeployment请求
func NewDefaultDeleteDeploymentRequest() *DeleteDeploymentRequest {
	return &DeleteDeploymentRequest{}
}

// NewDeleteDeploymentRequest 创建DeleteDeployment请求
func NewDeleteDeploymentRequest(name string) *DeleteDeploymentRequest {
	return &DeleteDeploymentRequest{
		Name: name,
	}
}

// GetDeploymentRequest 获取Deployment请求结构体
type GetDeploymentRequest struct {
	Name string `json:"name" validate:"required"` // Deployment名称
}

// NewDefaultGetDeploymentRequest 创建默认的GetDeployment请求
func NewDefaultGetDeploymentRequest() *GetDeploymentRequest {
	return &GetDeploymentRequest{}
}

// NewGetDeploymentRequest 创建GetDeployment请求
func NewGetDeploymentRequest(name string) *GetDeploymentRequest {
	return &GetDeploymentRequest{
		Name: name,
	}
}

// ListDeploymentRequest 列出Deployment请求结构体
type ListDeploymentRequest struct {
	LabelMap map[string]string `json:"label_map"` // 标签映射
}

// NewDefaultListDeploymentRequest 创建默认的ListDeployment请求
func NewDefaultListDeploymentRequest() *ListDeploymentRequest {
	return &ListDeploymentRequest{
		LabelMap: make(map[string]string),
	}
}

// NewListDeploymentRequest 创建ListDeployment请求
func NewListDeploymentRequest() *ListDeploymentRequest {
	return &ListDeploymentRequest{
		LabelMap: make(map[string]string),
	}
}

// AddLabel 添加标签
func (r *ListDeploymentRequest) AddLabel(key, value string) *ListDeploymentRequest {
	r.LabelMap[key] = value
	return r
}

// PatchDeploymentFromJsonRequest Patch Deployment请求结构体
type PatchDeploymentFromJsonRequest struct {
	Name string      `json:"name" validate:"required"` // Deployment名称
	Data interface{} `json:"data" validate:"required"` // Patch数据
}

// NewDefaultPatchDeploymentFromJsonRequest 创建默认的PatchDeploymentFromJson请求
func NewDefaultPatchDeploymentFromJsonRequest() *PatchDeploymentFromJsonRequest {
	return &PatchDeploymentFromJsonRequest{}
}

// NewPatchDeploymentFromJsonRequest 创建PatchDeploymentFromJson请求
func NewPatchDeploymentFromJsonRequest(name string, data interface{}) *PatchDeploymentFromJsonRequest {
	return &PatchDeploymentFromJsonRequest{
		Name: name,
		Data: data,
	}
}

// PatchDeploymentFromJsonRequest Patch Deployment请求结构体
type PutDeploymentFromYamlRequest struct {
	YamlStr string `json:"yaml_str" validate:"required"` // YAML字符串
}

// NewDefaultPutDeploymentFromYamlRequest 创建默认的PutDeploymentFromYaml请求
func NewDefaultPutDeploymentFromYamlRequest() *PutDeploymentFromYamlRequest {
	return &PutDeploymentFromYamlRequest{}
}

// NewPatchDeploymentFromJsonRequest 创建PatchDeploymentFromJson请求
func NewPutDeploymentFromYamlRequest(yamlStr string) *PutDeploymentFromYamlRequest {
	return &PutDeploymentFromYamlRequest{
		YamlStr: yamlStr,
	}
}

// GetDeploymentPodsRequest 获取Deployment Pods请求结构体
type GetDeploymentPodsRequest struct {
	Name string `json:"name" validate:"required"` // Deployment名称
}

// NewDefaultGetDeploymentPodsRequest 创建默认的GetDeploymentPods请求
func NewDefaultGetDeploymentPodsRequest() *GetDeploymentPodsRequest {
	return &GetDeploymentPodsRequest{}
}

// NewGetDeploymentPodsRequest 创建GetDeploymentPods请求
func NewGetDeploymentPodsRequest(name string) *GetDeploymentPodsRequest {
	return &GetDeploymentPodsRequest{
		Name: name,
	}
}

// ExecCommandOnDeploymentPodsRequest 在Deployment Pods上执行命令请求结构体
type ExecCommandOnDeploymentPodsRequest struct {
	DeploymentName string        `json:"deployment_name" validate:"required"` // Deployment名称
	Container      string        `json:"container" validate:"required"`       // 容器名称
	Command        string        `json:"command" validate:"required"`         // 执行的命令
	MaxConcurrency int           `json:"max_concurrency"`                     // 最大并发数
	CmdTimeout     time.Duration `json:"cmd_timeout"`                         // 命令超时时间
}

// NewDefaultExecCommandOnDeploymentPodsRequest 创建默认的ExecCommandOnDeploymentPods请求
func NewDefaultExecCommandOnDeploymentPodsRequest() *ExecCommandOnDeploymentPodsRequest {
	return &ExecCommandOnDeploymentPodsRequest{
		MaxConcurrency: 5,
		CmdTimeout:     30 * time.Second,
	}
}

// NewExecCommandOnDeploymentPodsRequest 创建ExecCommandOnDeploymentPods请求
func NewExecCommandOnDeploymentPodsRequest(deploymentName, container, command string, maxConcurrency int, cmdTimeout time.Duration) *ExecCommandOnDeploymentPodsRequest {
	return &ExecCommandOnDeploymentPodsRequest{
		DeploymentName: deploymentName,
		Container:      container,
		Command:        command,
		MaxConcurrency: maxConcurrency,
		CmdTimeout:     cmdTimeout,
	}
}
